package com.lemo.smart.proxy;

import com.lemo.smart.annotation.Aspect;
import com.lemo.smart.annotation.Controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * Created by 罗选通 on 2017/12/26.
 */
@Aspect(Controller.class)
public class ControllerAspect extends AspectProxy {
  private static final Logger LOGGER = LoggerFactory.getLogger(ControllerAspect.class);

  private long begin;

  @Override
  public void after(Class<?> targetClass, Method targetMethod, Object[] methodParams) {
    System.out.println("Controller=>after=>" + targetClass.getName() + ":" + targetMethod.getName());
    System.out.println("時間：" + String.valueOf(System.currentTimeMillis() - begin));
  }

  @Override
  public void before(Class<?> targetClass, Method targetMethod, Object[] methodParams) {
    LOGGER.info("Controller=>before=>" + targetClass.getName() + ":" + targetMethod.getName() + ":" + Arrays.toString(methodParams));
    begin = System.currentTimeMillis();
  }
}
